package ithemaday14.Test4;
public class GirlFriendTest {
    public static void main(String[] args) {
        GirlFriend []arr=new GirlFriend[4];
        GirlFriend g1=new GirlFriend ("zhangsan",18,"男","唱歌");
        GirlFriend g2=new GirlFriend ("lis",19,"男","跳舞");
        GirlFriend g3=new GirlFriend ("wangwu",20,"女","打篮球");
        GirlFriend g4=new GirlFriend ("hhh",21,"女","化妆");
        arr[0]=g1;
        arr[1]=g2;
        arr[2]=g3;
        arr[3]=g4;
        double ret=avg(arr);
        System.out.println(ret);
        int count=fun(arr,ret);
        System.out.println(count);
    }
    public static double avg(GirlFriend[] arr){
        double sum=0;
        for(int i=0;i<arr.length;i++){
            sum+=arr[i].getAge();
        }
        return sum/arr.length;
    }
    public static int fun(GirlFriend[] arr,double ret){
        int count=0;
        for (int i = 0; i < arr.length; i++) {
            if(ret>arr[i].getAge()){
                count++;
                System.out.println(arr[i].getName()+" "+arr[i].getAge()+" "+arr[i].getGender()+" "+arr[i].getAge());
            }
        }
        return count;
    }
}
